package cn.hd01.repository;

import javax.transaction.Transactional;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import cn.hd01.repository.entity.Servant;

@Repository
public interface ServantRepository extends JpaRepository<Servant, Integer> {
	
	Page<Servant> findAll(Specification<Servant> spec, Pageable pageable);
	
	Page<Servant> findAll(Specification<Servant> spec);
	
	@Modifying
	@Transactional
	@Query(value = "update Servant set name =?1, phone_no =?2, mail = ?3, address = ?4, update_time = now() where id=?5")
	int updateServant(String name, String phoneNo, String email, String address, Integer id);
	
}
